package provider;

import provider.WzXML.XMLWZFile;
import server.ServerProperties;

import java.io.File;

public class MapleDataProviderFactory {
    private static String wzPath;

    private static MapleDataProvider getWZ(Object in) {
        return getWZ(in, false);
    }

    private static MapleDataProvider getWZ(Object in, boolean provideImages) {
        if (in instanceof File) {
            File fileIn = (File) in;
            return new XMLWZFile(fileIn);
        }
        throw new IllegalArgumentException("Can't create data provider for input " + in);
    }

    public static MapleDataProvider getDataProvider(File in) {
        return getWZ(in);
    }

    public static MapleDataProvider getDataProvider(String path) {
        return getWZ(fileInWZPath(path));
    }

    public static File fileInWZPath(String filename) {
        return new File(MapleDataProviderFactory.wzPath, filename);
    }

    static {
        wzPath = ServerProperties.getProperty("cc.wzpath", "wz");
    }
}
